package com.liuwei.learning.restful;

import com.liuwei.learning.dao.ArticleJDBCDAO;
import com.liuwei.learning.jpa.testdb1.Article;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@RunWith(SpringRunner.class)
@AutoConfigureWebMvc
@SpringBootTest
public class ArticleRestControllerTest5 {

    @Resource
    private ArticleJDBCDAO articleJDBCDAO;

    @Resource
    private JdbcTemplate primaryJdbcTemplate;

    @Resource
    private JdbcTemplate secondaryJdbcTemplate;

    @Test
    public void saveArticle() {
        articleJDBCDAO.save(Article.builder().author("bruceliu")
        .title("primaryJdbcTemplate")
        .content("learning spring boot test test content input")
        .createTime(new Date()).build(),primaryJdbcTemplate);

        articleJDBCDAO.save(Article.builder().author("bruceliu")
                .title("secondaryJdbcTemplate")
                .content("learning spring boot test test content input")
                .createTime(new Date()).build(),secondaryJdbcTemplate);


    }
}
